import { SpeakerItem } from "../view/msgSpeaker/SpeakerItem";
import { ObjectPool } from "../../../com/gengine/utils/pools/ObjectPool";
import { PlayerMiniInfo } from "../model/PlayerMiniInfo";
import { MsgTypeImpl } from "./MsgTypeImpl";
import { GameController } from "../mvc/GameController";
import { ChatModule } from "../../../modules/ChatModule";
//class MsgSpeakerImpl
    
    export  class MsgSpeakerImpl /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._noticesArr = [];
            this._infoArr = [];
            this.mouseEnabled = false;
            return;
        }

        /* internal  */onNoticeHide(arg1: SpeakerItem): void
        {
            var loc1=false;
            this._noticesArr.shift();
            this._infoArr.shift();
            removeChild(arg1);
            arg1.dispose();
            ObjectPool.disposeObject(arg1, SpeakerItem);
            this._itemShowing = false;
            if (this._noticesArr.length > 0) 
            {
                this._itemShowing = true;
                loc1 = true;
                addChild(this._noticesArr[0]);
                this._noticesArr[0].init(this._infoArr[0].playerMiniInfo, this._infoArr[0].content, this._infoArr[0].type);
                this._noticesArr[0].updateData(this.onNoticeHide, loc1);
                this.setPxy();
            }
            return;
        }

        public showSpeakerNotice(arg1: PlayerMiniInfo, arg2: string, arg3: MsgTypeImpl): void
        {
            var loc1=false;
            var loc2=null;
            loc2 = ObjectPool.getObject(SpeakerItem);
            this._noticesArr.push(loc2);
            this._infoArr.push({"playerMiniInfo": arg1, "content": arg2, "type": arg3});
            if (!this._itemShowing) 
            {
                this._itemShowing = true;
                loc1 = true;
                addChild(loc2);
                loc2.init(arg1, arg2, arg3);
                loc2.updateData(this.onNoticeHide, loc1);
                this.setPxy();
            }
            return;
        }

        public setPxy(): void
        {
            var loc1=this._noticesArr[0];
            if (loc1) 
            {
                loc1.x = 0;
                loc1.y = (GameController.chat.view as ChatModule).y - (GameController.chat.view as ChatModule).height - 90;
            }
            return;
        }

        /* internal */ /* var */_noticesArr: Array<any>;

        /* internal */ /* var */_itemShowing: Boolean=false;

        /* internal */ /* var */_infoArr: Array<any>;
    }
